<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>绑定身份证</title>

    <link href="css/mui.css" rel="stylesheet" />
    <link href="css/user.css" rel="stylesheet" />
</head>

<body>
    <div id="app" v-cloak>
        <header class="mui-bar mui-bar-nav header">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h2 class="mui-title">绑定身份证</h2>
        </header>


        <div id="pullrefresh" class="mui-content" style="background: #f2f2f2;">
            <div class="userInfo">
                <div class="userIndexList">
                    <ul class="mui-table-view">
                        <li class="mui-table-view-cell" style="font-size: 0.3rem;">
                            <span>
                                <span>身份证号</span>
                                <div class="fl_right">
                                    <div class="mtable_rightInput">
                                        <input v-model='inputArr[0]' type="text" name="" placeholder="输入身份证号" onblur="this.placeholder='输入身份证号'" onfocus="this.placeholder=''"
                                            class="uil_input">
                                    </div>
                                </div>
                            </span>
                        </li>
                        <li class="mui-table-view-cell" style="font-size: 0.3rem;">
                            <span>
                                <span>真实姓名</span>
                                <div class="fl_right">
                                    <div class="mtable_rightInput">
                                        <input v-model='inputArr[1]' type="text" name="" placeholder="输入真实姓名" onblur="this.placeholder='输入真实姓名'" onfocus="this.placeholder=''"
                                            class="uil_input">
                                    </div>
                                </div>
                            </span>
                        </li>
                    </ul>
                </div>

                <div class="userInfoSubmit" @click="bindCard">
                    <span href="#" class="btn-red btn-bloak">确定提交</span>
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/mui.min.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/rem.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>

<script type="text/javascript">
    'use strict'

    $(document).ready(function () {
        if (!sessionStorage.getItem("Authorization")) {
            mui.alert('', '请先登录', function () {
                window.location.href = 'login.html'
            })
        }
        new Vue({
            el: '#app',
            data: {
                inputArr: []
            },
            methods: {
                /**
                 *  银行卡绑定
                 */
                bindCard: function () {
                    let url = 'biz/api/getcertification',
                        that = this,
                        reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/

                    if (!that.inputArr[0]) {
                        mui.alert('', '身份证号不能为空', function () {
                        })
                    } else {
                        if (!reg.test(that.inputArr[0])) {
                            mui.alert('', '请输入正确的身份证号', function () {
                                that.inputArr = []
                            })
                        } else {
                            if (!that.inputArr[1]) {
                                mui.alert('', '姓名不能为空', function () { })
                            } else {
                                let bindCardSuc = (data) => {
                                    // console.log(data)
                                    mui.alert('', data.msg, function () {
                                    })

                                    if (data.code === 1000) {
                                        window.location.href = 'user_card_ed.html?name=' + that.inputArr[1] + '&card=' + that.inputArr[0]
                                    }
                                },

                                    bindCardErr = (err) => {
                                        console.log(err)
                                    }

                                common.ajax(url, {
                                    memName: that.inputArr[1],
                                    idCard: that.inputArr[0]
                                }, bindCardSuc, bindCardErr)
                            }
                        }
                    }
                }
            }
        })
        $('.nav-list a').eq(4).addClass('mui-active');
        mui('body').on('tap', 'a', function () {
            if (this.href) {
                document.location.href = this.href;
            }
        });

    })
</script>

</html>